package com.lcq.userscenter.common.util;

import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * 
 * 常量类
 * @author ASUS_LCQ
 *
 */
public class ConstatFinalUtil
{
	/**
	 * 日志对象
	 */
	public static Logger LOGGER = LogManager.getLogger(ConstatFinalUtil.class);
	/*读取属性文件*/
	public static ResourceBundle BUNDLE = ResourceBundle.getBundle("common");
	/*连接超时*/
	public static int CONNECT_TIMEOUT = 10000;
	/*读取超时*/
	public static int READ_TIMEOUT = 10000;
	/*存储所有的token,键:token,值:管理员信息对应的JSON*/
	public static Map<String, JSONObject> TOKENS_MAP = new HashMap<String, JSONObject>();
	/*JSON配置文件*/
	public static JSONObject RESOURCE_JSON = new JSONObject();
	/*JSON配置文件 , info信息*/
	public static JSONObject INFO_JSON = new JSONObject();	
	/*存储随机数的字码表*/
	public static String ALLSTR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	
	static
	{
		FileUtil filUtil = new FileUtil();
		try
		{
			String resourceStr = filUtil.readFile(ConstatFinalUtil.class.getClassLoader().getResourceAsStream("resourceInfo.json"));
			RESOURCE_JSON = (JSONObject) JSON.parse(resourceStr);
			/*获取JSON配置文件中info信息*/
			INFO_JSON = RESOURCE_JSON.getJSONObject("info");
			ConstatFinalUtil.LOGGER.info("JSON配置文件");
		} catch (Exception e)
		{
			ConstatFinalUtil.LOGGER.info("JSON配置文件转换报错了");
		}
	}
	
}